﻿@model Apps.Models.WMS.WMS_ReturnOrderModel
@using Apps.Web.Core;
@using Apps.Common;
@using Apps.Models.WMS;
@using Apps.Web;
@using Apps.Locale;
@using Apps.Models.Sys;
@{
    ViewBag.Title = "创建";
    Layout = "~/Views/Shared/_Index_LayoutEdit.cshtml";
    List<permModel> perm = null;
}

<script type="text/javascript">
    $(function ()
    {
        $('#Lot').combogrid({
            panelWidth: 300,
            panelHeight: 150,
            idField: 'LotDisp',
            textField: 'LotDisp',
            url: '@Url.Action("GetLotsByPart", "Inv")',
            method: 'post',
            editable: false,
            onSelect: onSelect,
            columns: [[
                { field: 'Lot', title: '批次号', width: 50, hidden: true },
                {
                    field: 'LotDisp', title: '批次号', width: 50
                },
                {field:'Qty',title:'现有量',width:50},
                { field: 'StockQty', title: '备料数', width: 80, sortable: true, align: 'right' },
                { field: 'AvailableQty', title: '可用数量', width: 80, sortable: true, align: 'right' }
            ]],
            fitColumns: true
        });

        $("#btnSave").click(function () {
            if ($("form").valid()) {
                $.ajax({
                    url: "@Url.Action("Create")",
                    type: "Post",
                    data: $("form").serialize(),
                    dataType: "json",
                    success: function (data) {
                        if (data.type == 1) {
                            window.parent.frameReturnByMes(data.message);
                            window.parent.frameReturnByReload(true);
                            window.parent.frameReturnByClose()
                        }
                        else {
                            window.parent.frameReturnByMes(data.message);
                        }
                    }
                });
            }
            return false;
        });
        $("#btnReturn").click(function () {
             window.parent.frameReturnByClose();
        });

    });

    function onSelect(index, row)
    {
        $("#Qty").html(row.AvailableQty);
    }

    function LoadLot()
    {
        var invId = $("#InvId").val();
        var subInvId = "";
        var partId = $("#PartID").val();
        $("#Lot").combogrid('grid').datagrid("load", { partId: partId, invId: invId });
    };

    function frameReturnByClose()
    {
        $("#modalwindow").window('close');
    }
    function frameReturnByMes(mes) 
    {
        $.messageBox5s(Lang.Tip, mes);
    }
</script>
<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
<div class="mvctool bgb">
    @Html.ToolButton("btnSave", "fa fa-save", Resource.Save, ref perm, "Save", true)
    @Html.ToolButton("btnReturn", "fa fa-reply", Resource.Reply, false)
</div>
@using (Html.BeginForm())
{
    @Html.HiddenFor(model => model.Id, new { @Value = 0 })
    <input id="CreateTime" type="hidden" name="CreateTime" value="2000-1-1" />
    <table class="formtable">
        <tbody>
            @*<tr>
                    <th>
                        @Html.LabelFor(model => model.ReturnOrderNum)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.ReturnOrderNum)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.ReturnOrderNum)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.AIID)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.AIID)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.AIID)</td>
                </tr>*@
            <tr>
                <th>
                    @Html.LabelFor(model => model.PartID)：
                </th>
                <td>
                    @*@Html.EditorFor(model => model.PartID)*@
                    <div style="height:0;width:0;overflow:hidden">
                        @Html.EditorFor(model => model.PartID)
                    </div>
                    <input id="PartList" name="PartList" readonly="readonly" type="text" style="width: 180px; display: inline; background: #dedede; ">
                    <a class="fa fa-plus-square color-gray fa-lg" href="javascript:showSelPart()"></a>
                    <script type="text/javascript">
                        function showSelPart()
                        {
                            $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/WMS/Part/PartLookUp'></iframe>");
                            $("#modalwindow").window({ title: '选择物料', width: SetGridWidthSub(20), height: SetGridHeightSub(45), iconCls: 'fa fa-plus' }).window('open');
                        }

                        function SetSelResultForPart(result, resultName)
                        {
                            $("#PartID").val(result);
                            $("#PartList").val(resultName);
                            LoadLot();
                        }

                    </script>
                </td>
                <td>@Html.ValidationMessageFor(model => model.PartID)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.SupplierId)：
                </th>
                <td>
                    @*@Html.EditorFor(model => model.SupplierId)*@
                    <div style="height:0;width:0;overflow:hidden">
                        @Html.EditorFor(model => model.SupplierId)
                    </div>
                    <input id="SupplierList" name="SupplierList" readonly="readonly" type="text" style="width: 180px; display: inline; background: #dedede; ">
                    <a class="fa fa-plus-square color-gray fa-lg" href="javascript:showSelSupplier()"></a>
                    <script type="text/javascript">
                        function showSelSupplier()
                        {
                            $("#modalwindow").html("<iframe width='100%' height='100%' scrolling='no' frameborder='0'' src='/WMS/Supplier/SupplierLookUp'></iframe>");
                            $("#modalwindow").window({ title: '选择供应商', width: SetGridWidthSub(20), height: SetGridHeightSub(45), iconCls: 'fa fa-plus' }).window('open');
                        }

                        function SetSelResult(result, resultName)
                        {
                            $("#SupplierId").val(result);
                            $("#SupplierList").val(resultName);
                        }

                    </script>
                </td>
                <td>@Html.ValidationMessageFor(model => model.SupplierId)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.InvId)：
                </th>
                <td>
                    @*@Html.EditorFor(model => model.InvId)*@
                    @Html.DropDownListFor(model => model.InvId, ViewBag.Inv as SelectList, new { @onchange = "LoadLot()" })
                </td>
                <td>@Html.ValidationMessageFor(model => model.InvId)</td>
            </tr>,
            @*<tr>
                    <th>
                        @Html.LabelFor(model => model.SubInvId)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.SubInvId)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.SubInvId)</td>
                </tr>*@
            @*<tr>
                    <th>
                        @Html.LabelFor(model => model.ReturnQty)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.ReturnQty)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.ReturnQty)</td>
                </tr>*@
            <tr>
                <th>
                    批次号：
                </th>
                <td>
                    <input id="Lot" name="Lot" value="">
                    <label id="Qty" for="Lot" name="Qty"></label>                    
                </td>
                <td>@Html.ValidationMessageFor(model => model.Lot)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.AdjustQty)：
                </th>
                <td>
                    @Html.EditorFor(model => model.AdjustQty)
                </td>
                <td>@Html.ValidationMessageFor(model => model.AdjustQty)</td>
            </tr>
            <tr>
                <th>
                    @Html.LabelFor(model => model.Remark)：
                </th>
                <td>
                    @Html.EditorFor(model => model.Remark)
                </td>
                <td>@Html.ValidationMessageFor(model => model.Remark)</td>
            </tr>
            @*<tr>
                    <th>
                        @Html.LabelFor(model => model.PrintStaus)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.PrintStaus)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.PrintStaus)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.PrintDate)：
                    </th>
                    <td >
                       @Html.TextBoxFor(model => model.PrintDate, new { @onClick = "WdatePicker()",@style = "width: 105px" })
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.PrintDate)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.PrintMan)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.PrintMan)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.PrintMan)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.ConfirmStatus)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.ConfirmStatus)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.ConfirmStatus)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.ConfirmMan)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.ConfirmMan)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.ConfirmMan)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.ConfirmDate)：
                    </th>
                    <td >
                       @Html.TextBoxFor(model => model.ConfirmDate, new { @onClick = "WdatePicker()",@style = "width: 105px" })
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.ConfirmDate)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.Attr1)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.Attr1)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.Attr1)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.Attr2)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.Attr2)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.Attr2)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.Attr3)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.Attr3)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.Attr3)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.Attr4)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.Attr4)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.Attr4)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.Attr5)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.Attr5)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.Attr5)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.CreatePerson)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.CreatePerson)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.CreatePerson)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.ModifyPerson)：
                    </th>
                    <td>
                        @Html.EditorFor(model => model.ModifyPerson)
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.ModifyPerson)</td>
                </tr>
                <tr>
                    <th>
                        @Html.LabelFor(model => model.ModifyTime)：
                    </th>
                    <td >
                       @Html.TextBoxFor(model => model.ModifyTime, new { @onClick = "WdatePicker()",@style = "width: 105px" })
                    </td>
                    <td>@Html.ValidationMessageFor(model => model.ModifyTime)</td>
                </tr>*@
        </tbody>
    </table>
}

